Attribute VB_Name = "ModCmdLine"
Option Explicit

Public Sub main()
    If (LCase(GetFirstcommandLine) = "now") Then
        ShutdownSystem (EWX_LOGOFF Or EWX_FORCE Or EWX_POWEROFF)
    Else
        If (MsgBox("Vuoi chiudere Windows ?", vbYesNo Or vbDefaultButton2, "Chiusura di Windows") = vbYes) Then
            ShutdownSystem (EWX_LOGOFF Or EWX_FORCE Or EWX_POWEROFF)
        End If
    End If

End Sub

Public Function GetFirstcommandLine() As String
    On Error GoTo errore
    Dim cmdLineString As String
    Dim token As String
    cmdLineString = Trim(Command())
    token = InStr(1, cmdLineString, " ")
    If (token <= 0) Then
        GetFirstcommandLine = cmdLineString
    Else
        GetFirstcommandLine = Left(cmdLineString, InStr(1, cmdLineString, " "))
    End If
    Exit Function
errore:
    GetFirstcommandLine = vbNullString
End Function
